/*** Eclipse Class Decompiler plugin, copyright (c) 2016 Chen Chao (cnfree2000@hotmail.com) ***/
package controller;

import entity.Exampaper;
import entity.Novalchapter;
import entity.Novel;
import entity.Vacabulary;
import java.io.PrintStream;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import service.ExamService;
import service.NovalService;
import service.VocabularyService;

@Controller
public class DispatchAction {

	@Resource
	private VocabularyService vocabularyService;

	@Resource
	private ExamService examService;

	@Resource
	private NovalService novalService;

	@RequestMapping({ "/index" })
	public String index(Model model) {
		return "index";
	}

	@RequestMapping({ "/vocabulary" })
	public String vocabulary(Model model) {
		Vacabulary voca = this.vocabularyService.getVoca(1);

		model.addAttribute("voca", voca);
		return "vocabulary";
	}

	@RequestMapping({ "/backmanage" })
	public String backmanage() {
		return "backmanage";
	}

	@RequestMapping({ "/login" })
	public String login() {
		return "login";
	}

	@RequestMapping({ "/practice" })
	public String practice(Model model, Long paperid) {
		System.out.println(paperid);
		Exampaper paper = this.examService.getPaperByPaperId(paperid);
		List quests = this.examService.getQuestByPaperId(paperid);
		model.addAttribute("paper", paper);
		model.addAttribute("quests", quests);
		return "practice";
	}

	@RequestMapping({ "/registe" })
	public String registe() {
		return "registe";
	}

	@RequestMapping({ "/practiceanswer" })
	public String practiceanswer() {
		return "practiceanswer";
	}

	@RequestMapping({ "/practicecommand" })
	public String practicecommand(Model model) {
		List papers = this.examService.getPapers();
		model.addAttribute("papers", papers);
		return "practicecommand";
	}

	@RequestMapping({ "/noval" })
	public String noval(Model model, Long novalid, int chapterid) {
		System.out.println(novalid + ":" + chapterid);
		Novalchapter chapter = this.novalService.getNovelchapter(chapterid,
				novalid.longValue());
		Novel novel = this.novalService.getNovel(novalid.longValue());
		model.addAttribute("chapter", chapter);
		model.addAttribute("novel", novel);
		return "noval";
	}

	@RequestMapping({ "/novalcommand" })
	public String novalcommand(Model model) {
		List novels = this.novalService.getNovels();
		model.addAttribute("novels", novels);
		return "novalcommand";
	}

	@RequestMapping({ "/makeplan" })
	public String makeplan(Model model) {
		List vos = this.vocabularyService.getvocaType();
		System.out.println(vos);
		model.addAttribute("vos", vos);
		return "makeplan";
	}
}